package com.eunion.web.cms.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eunion.web.cms.entity.User;
import com.eunion.web.cms.service.UserService;
import com.eunion.web.common.base.BaseService;
import com.eunion.web.common.base.BaseTableCommonController;

/**
 * 会员
 */
@Controller
@RequestMapping("/api/user")
public class UserResource extends BaseTableCommonController<User, Long> {

    @Override
    protected BaseService<User, Long> getBaseService() {
        return userService;
    }
    
    @Autowired
    private UserService userService;

    /**
     * 进入会员管理页面
     * @return
     */
    @RequestMapping("/index")
    public String index() {
        return getUrlBase();
    }

    @Override
    protected String getUrlBase() {
        return "admin/user/user";
    }

    /**
     * 进入会员充值记录页面
     * @return
     */
    @GetMapping("/recharge/{phone}")
    public String getRechargeBy(@PathVariable String phone, Model model) {
        model.addAttribute("phone", phone);
        return getUrlBase().concat("-recharge-record");
    }
}
